package com.example.zheng.qq.controller;


import android.support.v4.view.ViewPager;
import android.view.View;

public class TogglePicture implements ViewPager.PageTransformer{
    public static final float MIN_SCAL=0.75f;

    @Override
    public void transformPage(View page, float position) {
        int pageWidth=page.getWidth();
        if(position<-1){
            page.setAlpha(0);
        }else if(position<=0){
            page.setAlpha(1);
            page.setTranslationX(0);
            page.setScaleX(1);
            page.setScaleY(1);

        }else if(position<=1){
            page.setAlpha(1-position);
            page.setTranslationX(-position*pageWidth);
            float translaton=MIN_SCAL+(1-MIN_SCAL)*(1-Math.abs(position));
            page.setScaleX(translaton);
            page.setScaleY(translaton);
        }else{
            page.setAlpha(0);
        }

    }

}
